<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
            给定两个字符串形式的非负整数 num1 和num2 ，计算它们的和并同样以字符串形式返回。
            你不能使用任何內建的用于处理大整数的库（比如 BigInteger）， 也不能直接将输入的字符串转换为整数形式。 
        */
        var addStrings = function (num1, num2) {
            function strSum(str) {
                let numArr = str.split('');
                const length = numArr.length;
                let res = 0;
                for (let i = 0; i < length; i++) {
                    res += ((parseInt(numArr[i])) * (Math.pow(10, length - i - 1)));
                }
                return res;
            }
            let sum = strSum(num1);
            return sum;
        };
        console.log(addStrings('9333852702227987', '85731737104263'));
    </script>
</body>

</html>